package com.hfuuTaf.config;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class loginIntercept implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Object info = request.getSession().getAttribute("userLoginInfo");
        //就拦截viva二个页面
        if(request.getRequestURI().contains("/Viva")){
            //放行,判断什么情况下可以登录
            if(info!=null){
                return true;
            }
        }
        request.getRequestDispatcher("/hfuuTaf/login").forward(request,response);
        return false;
    }
}
